<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../include/tag.jsp" %>
<link rel="stylesheet" href="${ctx}/css/ui/system/member/memberIndex.css">

<%--div class="c-time-list-header">
    <div class="ovh">
        <span class="title f20">账户中心</span>
    </div>
</div>--%>

<!-- 个人资料，余额 -->
<div class="member-index-top">
    <div class="common-flex">
        <div class="u-box-inner common-flex u-user-info">
            <img class="logo mr20" src="<c:if test="${ member.logo!= null}">${member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="">
            <div>
                <div class="mb10">
                    <span class="f20">${member.realname}</span>
                   <%-- <span class="iconfont icon-huangguan huangguan-big" ${member.isExpert != 1 ? 'style="display: none;"' : '' } ></span>--%>
                    <c:choose>
                        <c:when test="${isChildAccount}">
                            <a href="${ctx}/member/group/childForm.do" target="_self"
                               class="layui-btn layui-btn-danger layui-btn-sm ml10">
                                <i class="iconfont icon-edit btn-icon"></i> 编辑资料</a>
                        </c:when>
                        <c:otherwise>
                            <a href="${ctx}/system/member/memberForm.do" target="_self"
                               class="layui-btn layui-btn-danger layui-btn-sm ml10">
                                <i class="iconfont icon-edit btn-icon"></i> 编辑资料</a>
                        </c:otherwise>
                    </c:choose>
                </div>
                <c:if test="${isChildAccount}">
                    <div class="mb5">
                        <span>主账号：</span>
                        <span>${partnerName}</span>
                    </div>
                </c:if>
                <div class="mb5">
                    <span>账号等级：</span>
                    <c:if test="${null == productPackage}">
                        <%--<span>无</span>--%>
                        <c:if test="${sysConfig != null && fn:trim(sysConfig.value) == 'true'}">
<%--                            <a href="${ctx}/charge/package/packageList.do" target="_self"
                               class="layui-btn layui-btn-danger layui-btn-sm ml10">
                                <i class="iconfont icon-choiceness btn-icon"></i> 开通</a>--%>
                        </c:if>
                    </c:if>
                    <c:if test="${null != productPackage}">
                        <c:if test="${productPackage.type == 4}">
                            <c:if test="${productPackage.systemType == 1}">
                                <span>社群</span>
                            </c:if>
                            <c:if test="${productPackage.systemType == 2}">
                                <span>企业经典版</span>
                            </c:if>
                        </c:if>
                        <c:if test="${productPackage.type != 4}">
                            <span>${productPackage.name}</span>
                        </c:if>
                        <c:if test="${sysConfig != null && fn:trim(sysConfig.value) == 'true'}">
<%--                            <a href="${ctx}/charge/package/packageList.do" target="_self"
                               class="layui-btn layui-btn-danger layui-btn-sm ml10">
                                <i class="iconfont icon-choiceness btn-icon"></i> 升级</a>--%>
                        </c:if>
                    </c:if>

<%--                    <a href="${ctx}/charge/package/moduleList.do" target="_self"
                       class="layui-btn layui-btn-danger layui-btn-sm ml10">
                        <i class="iconfont icon-choiceness btn-icon"></i> 增值服务</a>--%>
                </div>
                <c:if test="${not empty expirationTime}">
                    <div>
                        <span>有效期：</span>
                        <span><fmt:formatDate value="${expirationTime}" pattern="yyyy-MM-dd HH:mm"/></span>
                    </div>
                </c:if>
            </div>
        </div>
        <div class="u-box-split"></div>
        <div class="u-box-inner">
            <div class="u-info">
                <p class="f18 red b"><fmt:formatNumber pattern="#,###.##"
                                                       value="${totalPayment}"/></p>
                <p class="f14">累计资金（元）</p>
                  <c:if test="${!isBand}">
                <a href="${ctx}/moneyManagement/allMoneyList.do" target="_self"
                   class="layui-btn layui-btn-danger layui-btn-sm mt5"
                   style="padding-left: 15px; padding-right: 15px;"><i
                        class="iconfont icon-recharge btn-icon"></i>
                    详情</a>
                  </c:if>
<%--                <c:if test="${!isBand}">
                    <a href="${ctx}/wallet/withdrawals/withdrawalForm.do" target="_self"
                       class="layui-btn layui-btn-danger layui-btn-sm mt5"
                       style="padding-left: 15px; padding-right: 15px;"><i
                            class="iconfont icon-recharge btn-icon"></i>
                        提现</a>
                </c:if>--%>
            </div>
        </div>
        <c:if test="${packageCount.isOpen == 1}">
            <div class="u-box-split"></div>
            <div class="u-box-inner">
                <div class="u-info">
                    <p class="f18 red b">${packageCount.totalNum - packageCount.useNum}</p>
                    <p class="f14"><span class="dib vm">短信剩余(条)</span><a href="javascript:void(0)" id="question_icon"
                                                                         title=""><i
                            class="iconfont icon-question f18"></i></a></p>
                    <a href="${ctx}/charge/package/smsPackageList.do" target="_self"
                       class="layui-btn layui-btn-danger layui-btn-sm mt5">充值</a>
                </div>
                    <%--<a href="javascript:countSettings()" target="_self" class="layui-btn layui-btn-danger layui-btn-sm ml10">配置</a>--%>
            </div>
        </c:if>
        <span></span>
    </div>

</div>
<script type="text/javascript">
    var form = null, element = null;
    $(function () {
        layui.use(['element', 'form'], function () {
            element = layui.element, form = layui.form;

            element.on('tab', function (data) {
                if (data.index == 0) {
                    location.href = "${ctx}/order/order/orderList.do";
                } else if (data.index == 1) {
                    location.href = "${ctx}/order/order/withdrawList.do";
                } else if (data.index == 2) {
                    location.href = "${ctx}/order/order/tradeList.do";
                }
            });
        });
        $("#question_icon").mouseover(function () {
            index = txz.openQTip(this, '首次使用，特赠送您<span class="orange">1000条</span>短信，超出部分<span class="orange">0.08元/条</span>，已使用<span class="orange">${packageCount.useNum}条</span>，剩余<span class="orange">${packageCount.totalNum - packageCount.useNum}条</span>');
        }).mouseout(function () {
            layer.close(index);
        });
    });

    /**
     * 短信配置
     */
    function countSettings() {
        var index = layer.open({
            type: 1,
            area: '290px',
            title: '短信配置',
            content: $("#settingsDialog"),
            btn: ['提交', '取消'],
            success: function () {
                $("#settingsDialog").find("[name=warnNum]").val('${packageCount.warnNum}');
            },
            end: function () {
                $("#settingsDialog").find("[name=warnNum]").val('');
            },
            yes: function () {
                var warnNum = $("#settingsDialog").find("[name=warnNum]").val();
                var warnMsg = checkNum(warnNum, "预警数量");
                if (warnMsg != "") {
                    util.layerMsgError(warnMsg);
                    return null;
                }
                var index = layer.load(1);
                $.post("${ctx}/system/member/saveSettings.do", $("#settingsDialog form").serializeArray(), function (ret) {
                    layer.close(index);
                    if (ret.success == true) {
                        util.layerMsgSuccess("提交成功", function () {
                            window.location.reload();
                        });
                    } else {
                        util.layerMsgError("提交失败")
                    }
                });
            }
        });
    }

    function checkNum(value, title) {
        var msg = '';
        if (value == "") {
            msg = title + "不能为空";
        } else if (!util.checkNumber(value)) {
            msg = "请输入正确的数字";
        } else if (parseInt(value) == 0) {
            msg = "请输入大于0的数字";
        }
        return msg;
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '账户中心',
            curr: true
        }]
    });
</script>